<script src="/public/js/islider.js"></script>
<script src="/public/js/islider_desktop.js"></script>
<?php $action['content'] = json_decode($action['content'],true);?>
<div style='height: 8rem'>
    <div class='_line'></div>
    <div class='_line'></div>
    <a href="#" onClick='opencode();'><b>点击－>关注公众号，查看订单。</b></a>
</div>
<div class="_preview_div">
    <div class='box'>                
        <h3><?php echo $action['action_name'];?></h3>
        <div style="height: 1rem"></div>
        <?php if($count>0){?>
        <div style="width:100%">
            <?php foreach($team as $k=>$v){?>
            <div style="float: left;width:13%">
                <div class='headimg'>
                    <img class='head_img' src="<?php echo $v['headimg'];?>"/>
                    <span style="width:4rem;height:1.8rem;display:block;text-overflow:hidden;white-space:nowrap;overflow: hidden;"><font style="font-size:1rem;color:black"><b><?php echo $v['nickname'];?></b></font></span>
                </div>
            </div>
            <?php } ?>
            <?php if($count>7){echo '...';}?>
            <div class="clearfix"></div>
            <br/><div style="height: 0.5rem"></div>
            <div style="width:100%;text-align: right;">共有<font style="color:red"><?php echo $count;?>人</font>参团</div>
        </div>
        <?php } ?>
        <div class="clearfix"></div>
        <div style="height: 1rem"></div>
        <span class='colors-size'><?php echo $action['intro'];?></span>
    </div>
    <div class='_line'></div>
    <link href="/public/css/action.css" rel="stylesheet">
    <div class='box'>
        <?php if($items){ $ids = $action['content']['ids'];?>
        <?php foreach($items as $k=>$v){?>
        <div style="width:100%">
            <div id="iSlider-effect-wrapper">
                <div id="non-looping_<?php echo $v['id'];?>" class="iSlider-effect"></div>
                <div class='img_number'><?php echo count($v['images']);?>图</div>
            </div>
        </div>
        <div style="clear:both"></div>
        <script>
            var picList_<?php echo $v['id'];?> = [
                        <?php foreach($v['images'] as $kk => $vv){ $image = explode('/',$vv['image']);$_img = array_pop($image);$image = implode('/',$image).'/'.'max_'.$_img;?>
                {
                width: '100%',
                        height: '100%',
                        content: "http://<?php echo IMAGE_DOMAIN_.$image;?>"
                } <?php if ($kk + 1 < count($v['images'])){echo ','; }?>
                        <?php } ?>
                ];
                //不循环 不自动播放
                var islider_<?php echo $v['id'];?> = new iSlider({
                data: picList_<?php echo $v['id'];?>,
                        dom: document.getElementById("non-looping_<?php echo $v['id'];?>"),
                        duration: 4000,
                        animateType: 'default',
                        isAutoplay: true,
                        isLooping: true,
                        hand: true,
                });
                islider_<?php echo $v['id'];?>.bindMouse();
        </script>
        <div>
                <span class='big_title'><?php echo $v['name'];?></span>&nbsp;&nbsp;&nbsp;&nbsp;
                <span class='small_title'><?php echo $v['title'];?></span>
            </div>
            <div class='cut_3'></div>
            <div class='cut'></div>
            <div class='cut_3'></div>
            <div>
                <span class='_price'><s>原价：￥<?php echo $v['old_price']/100;?></s></span>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <span class='_price'>拼团价：￥<?php echo $ids[$v['id']]/100;?></span>
            </div>
            <div class='cut_3'></div>
            <div class='cut'></div>
            <div class='cut_3'></div>
            <?php if($v['is_meal_set']==1){ ?>
            <div class='set_content'>
            套餐内容：<br/>
            <?php foreach($v['meal_set_items'] as $kk=>$vv){ ?>
            <a href="<?php echo shop_buildUrl('/user/shop/info?item_number='.$vv['item_number']);?>" ><b><?php echo $vv['name'];?></b></a>&nbsp;&nbsp;&nbsp;<?php echo $vv['number'];?>&nbsp;个/次<br/>
            <?php }?>
            </div>
            <div class='cut_3'></div>
            <div class='cut'></div>
            <?php }?>
            <div class='cut_3'></div>
            <div class='intro colors-size'>
                <?php echo $v['intro'];?>
            </div>
            <div class='cut_3'></div>
            <div class='cut'></div>
            <div class='cut_3'></div>
        <?php }?>
        <?php }else{?>
        <i><?php foreach($action['content']['content'] as $k=>$v){
        $v['old'] = $v['old']/100;$v['new'] = $v['new']/100;
        echo "<span><h4>".$k."：原价<s><span style='color:red'>".$v['old']."</span></s>&nbsp;&nbsp;拼团价<span style='color:red'>".$v['new']."</span><br/>内容：<span style='color:red'>".$v['content']."</span></span></h4>";
    }?>
        </i>
        <?php }?>
    </div>
    <!--<div class='box'>                
        <img src="<?php echo $action['logo'];?>" style="width:100%;" id="_banner_"/>
        <br/>
    </div>-->
    <div class='_line'></div>
    <div class='box'>
        <span class='colors'>活动日期:</span>
        <span class='colors-size'><?php echo date("Y年m月d日",$action['start_time']);?>&nbsp;至&nbsp;<?php echo date("Y年m月d日",$action['end_time']);?></span>
        </br>
        <span class="colors">使用截止日期:</span>
        <span class='colors-size'><?php echo date("Y年m月d日",$action['use_end_time']);?></span>
    </div>
    <div class='box'>
        <span class='colors'>联系人:</span>
        <span class='colors-size'><?php echo $store['person_charge'];?></span>
    </div>
    <div class='box'>
        <span class='colors'>tel:</span>
        <span class='colors-size'><?php echo $store['tel'];?></span>
    </div>
    <div class='_line'></div>
    <div class='box'>
        <img style='width:100%' src='http://apis.map.qq.com/ws/staticmap/v2/?center=<?php echo $store["latlng"];?>&zoom=13&size=600*300&maptype=roadmap&markers=size:large|color:0xff0000|label:P|<?php echo $store["latlng"];?>&key=5LTBZ-Z6PC5-WAGIB-QXGAX-JBVBF-XQBTP'/>
    </div>
    <div class='_line'></div>
    <div class='box'>
        <span class='colors'>地址:</span>
        <span class='colors-size'><?php echo $store['address'];?></span>
    </div>
    <div class='_line'></div>
    <form id="form">
    <div class='box'>
    <input style="width:100%;height:3rem" type="text" value="" id="mobile" placeholder="请填写手机号"/>
    </div>
        <div class='_line'></div>
        <div class='box'>
    <input style='width:60%;height:3rem' type="text" value="" id="_code" placeholder="请填验证码">
    &nbsp;&nbsp;&nbsp;<button type="button" id='subcode' style='width:30%'>获取验证码</button>
    </div>
    <div class='_line'></div>
    <div class='box'>
        <select style="width:100%;height:3rem" name="type" id="type">
    <?php foreach($items as $v){
        echo "<option value='".$v['id']."'>".$v['name']."</option>";
    }?>
    </select>
    </div>
    </form>
    <div style="height: 6rem"></div>
    <?php if($option!=true){?>
    <div class='box navbar-fixed-bottom' style="text-align: center;">
        <?php if(strlen(trim($_GET['team_number']))>1){?>
        <button class="btn btn-primary btn-lg" id='_add' type="button" style="width:49%;background-color:#FF79BC;border-color:white">我要参团</button>
        <button class="btn btn-primary btn-lg" id='_new' type="button" style="width:49%;background-color:#FF79BC;border-color:white">我要开团</button>
        <?php }else{?>
        <button class="btn btn-primary btn-lg" id='_new' type="button" style="width:98%;background-color:#FF79BC;border-color:white">我要开团</button>
        <?php }?>
    </div>
    <?php }?>
    <div class='box navbar-fixed-top' style="text-align: center;width:100%;height:6%;">
        <div  id='business_add' type="button" style="background-color:rgba(79, 79, 79, 0.7);width:49.8%;height:100%;border-color:#797979;float:left;color:white;font-size:14px;padding-top:1rem;">商家参与入口</div>
        <div  id='suggest' type="button" style="background-color:rgba(79, 79, 79, 0.7);width:49.8%;height:100%;border-color:#797979;float:right;color:white;font-size:14px;padding-top:1rem;">用户反馈</div>
    </div>

</div>
<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script type="text/javascript">
    function code() {
        var mobile = $("#mobile").val();
        $.ajax({url: "/user/barber/code?mobile=" + mobile, async: true, success: function (msg) {
                if (msg != 'true') {
                    alert(msg);
                    return false;
                }
                $("#subcode").text('60');
                $("#subcode").attr('disabled', 'disabled');
                var t = setInterval(function () {
                    var m = $("#subcode").text();
                    var str = parseInt(m) - 1;
                    if (str <= 0) {
                        str = '获取验证码';
                        $("#subcode").removeAttr('disabled');
                        clearInterval(t);
                    }
                    $("#subcode").text(str);
                }, 1000);
            }
        });
    }
    var _mobile = /^(((1[1-9]{1}[0-9]{1})|(15[0-9]{1}))+\d{8})$/
    $(document).ready(function () {
        $("#subcode").click(function(){
            code();
        });
        var weixin_str = '&nickname=<?php echo $name;?>&sex=<?php echo $sex;?>&headimg=<?php echo urlencode($photo);?>';
        $("#_add").click(function(){
            document.getElementsByTagName('body')[0].scrollTop=document.getElementsByTagName('body')[0].scrollHeight;
            var mobile = $("#mobile").val();
            var code = $("#_code").val();
            if(!_mobile.test(mobile)){
                alert('请先填写手机号');
                return false;
            }
            var type = $("#type").val();
            if(type.length<1){
                alert('请选择参与项目');
                return false;
            }
            var code = $("#_code").val();
            var mobile = $("#mobile").val();
            $.ajax({url: "/user/barber/checkcode?code=" + code + "&mobile=" + mobile, async: true, success: function (msg) {
                if (msg != 'true') {
                        alert('验证码错误');
                    }else{
                        var str = "&code="+code+"&mobile="+mobile+"&type="+encodeURI(type)+weixin_str;
                        window.location.href="<?php echo buildUrl('/user/order/createorder',(int)$_GET['barber_id']);?>&team_number=<?php echo $_GET['team_number'];?>&aid=<?php echo $action['id'];?>&verify=<?php echo $verify;?>"+str;
                    }
                }
            });

        });
        $("#_new").click(function(){
            document.getElementsByTagName('body')[0].scrollTop=document.getElementsByTagName('body')[0].scrollHeight;
            var mobile = $("#mobile").val();
            var code = $("#_code").val();
            if(!_mobile.test(mobile)){
                alert('请先填写手机号');
                return false;
            }
            var type = $("#type").val();
            if(type.length<1){
                alert('请选择参与项目');
                return false;
            }
            var code = $("#_code").val();
            var mobile = $("#mobile").val();
            $.ajax({url: "/user/barber/checkcode?code=" + code + "&mobile=" + mobile, async: true, success: function (msg) {
                if (msg != 'true') {
                        alert('验证码错误');
                    }else{
                        var str = "&code="+code+"&mobile="+mobile+"&type="+encodeURI(type)+weixin_str;
                        window.location.href="<?php echo buildUrl('/user/order/createorder',(int)$_GET['barber_id']);?>&aid=<?php echo $action['id'];?>&verify=<?php echo $verify;?>"+str;
                    }
                }
            });
            
        });

        //商家参与
        $('#business_add').click(function(){
            window.location.href="<?php echo buildUrl('/center/business/business_add',(int)$_GET['barber_id']);?>";
        });
        //用户反馈
        $('#suggest').click(function(){
            window.location.href="<?php echo buildUrl('/center/questionnaire/suggest',(int)$_GET['barber_id']);?>";
        });
    });
<?php if($weixin == true){?>
    wx.config({
        debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
        appId: '<?php echo WEIXIN_PAY_APP_ID;?>', // 必填，公众号的唯一标识
        timestamp: <?php echo $data["timestamp"];?>, // 必填，生成签名的时间戳
        nonceStr: '<?php echo $data["noncestr"];?>', // 必填，生成签名的随机串
        signature: '<?php echo $data["sign"];?>',// 必填，签名，见附录1
        jsApiList: ['onMenuShareTimeline','onMenuShareAppMessage'] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
    });
    wx.ready(function () {
        wx.onMenuShareTimeline({
            title: '<?php echo $action['action_name'] ;?>', // 分享标题
            link: '<?php echo $data["url"];?>', // 分享链接
            imgUrl: '<?php echo "http://".MAIN_DOMAIN.$logo;?>', // 分享图标
            success: function () { 


            },
            cancel: function () { 
                // 用户取消分享后执行的回调函数

            }
        });
        wx.onMenuShareAppMessage({
            title: '<?php echo $action['action_name'] ;?>', // 分享标题
            desc: "<?php echo strip_tags($action['intro']);?>", // 分享描述
            link: '<?php echo $data["url"];?>', // 分享链接
            imgUrl: '<?php echo "http://".MAIN_DOMAIN.$logo;?>', // 分享图标
            type: '', // 分享类型,music、video或link，不填默认为link
            dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
            success: function () { 
                // 用户确认分享后执行的回调函数

            },
            cancel: function () { 
                // 用户取消分享后执行的回调函数

            }
        });
    })
<?php }?>
</script>
<script type="text/javascript">
    function closecode(){
        $("#_qrcode").hide();
    }
    function opencode(){
        $("#_qrcode").show();
    }
</script>
<div id='_qrcode' style="text-align: center;width:100%;height:100%;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#8E8E8E',endColorstr='##8E8E8E');
    background-color:rgba(255, 255, 255, 0.7);position:fixed; _position:absolute; top:0;left:0; z-index:5000;display:none ">
    <?php if(strlen($store['code'])>0){?>
    <div style="padding-top:20rem">
    <img src="<?php echo $store['code'];?>" style='width:30rem;height:30rem'>
    </div>
    <div class='_line'></div>
    <a onclick='closecode();'><font style="font-size: 3rem;color:black"><b>关闭</b></font></a>
    <?php }?>
</div>
